bitkeeper revision 1.184 (3ea3068dWnCzvBRYV1RTpoVK29FlDg)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Sun, 20 Apr 2003 20:43:57 +0000 (20:43 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Sun, 20 Apr 2003 20:43:57 +0000 (20:43 +0000)
Many files:
  Removed the system-wide VIF list -- we now find VIFs via the task hashtable. Fixed a few synchronisation problems.

24 files changed:
tools/domain_builder/newdom
tools/domain_builder/vifinit
xen/arch/i386/apic.c
xen/arch/i386/ioremap.c
xen/arch/i386/smpboot.c
xen/arch/i386/traps.c
xen/common/dom0_ops.c
xen/common/dom_mem_ops.c
xen/common/domain.c
xen/common/kernel.c
xen/common/network.c
xen/common/schedule.c
xen/drivers/block/xen_block.c
xen/drivers/scsi/scsi.h
xen/include/hypervisor-ifs/network.h
xen/include/xeno/blkdev.h
xen/include/xeno/ide.h
xen/include/xeno/sched.h
xen/include/xeno/skbuff.h
xen/include/xeno/vif.h
xen/net/dev.c
xen/net/skbuff.c
xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_core.c
xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/vfr.c

index 196187292314099ea2a5732e9867fd65edc40e2a..7dc46a085428873da01a494770c6d48fb4ce217d 100755 (executable)
@@ -21,10 +21,6 @@ DOM=$?
 
 echo DOM= $DOM
 
-VIF=`cat /proc/xeno/dom$DOM/vif`
-
-echo VIF= $VIF
-
-$VIFINIT $VIF $IP
+$VIFINIT $DOM 0 $IP
 
 
index 58b50eaab0e6fd2b0e28100805ea7a85d6cc98f2..76a95e8b8a4058e28f1b86d6d80f6146e0b42133 100755 (executable)
@@ -7,19 +7,19 @@
 # 
 # Usage is:
 #
-#   vifinit [vif id] [dotted decimal ip address]
+#   vifinit [vif dom] [vif idx] [dotted decimal ip address]
 #
-if [ $# -ne 2 ] ; 
+if [ $# -ne 3 ] ; 
 then
-        echo "usage: vifinit [vif id] [dotted decimal ip address]"
+        echo "usage: vifinit [vif dom] [vif idx] [dotted decimal ip address]"
         exit
 fi
 
 #outbound rule:
-echo "ADD ACCEPT srcaddr=$2 srcaddrmask=255.255.255.255 srcint=$1 dstint=-1 proto=any" > /proc/vfr
+echo "ADD ACCEPT srcaddr=$3 srcaddrmask=255.255.255.255 srcdom=$1 srcidx=$2 dst=PHYS proto=any" > /proc/vfr
 
 #inbound rule:
-echo "ADD ACCEPT dstaddr=$2 dstaddrmask=255.255.255.255 srcint=-4 dstint=$1 proto=any" > /proc/vfr
+echo "ADD ACCEPT dstaddr=$3 dstaddrmask=255.255.255.255 src=ANY dstdom=$1 dstidx=$2 proto=any" > /proc/vfr
 
 #----] done.
 
index ba45f6ff19cc5fdec6cf333d3746188b6cea73bf..78cfcc2c09d55ceac94ab3e0207ba9e8325f58bc 100644 (file)
@@ -46,6 +46,7 @@
 #include <asm/pgalloc.h>
 #include <asm/hardirq.h>
 #include <asm/apic.h>
+#include <xeno/mm.h>
 
 #include <asm/timex.h>
 #include <xeno/ac_timer.h>
index cd97e124d7eb9cba89c0154be43a161a99b27593..bf24892367516f32048d316db4e74173bc6cf473 100644 (file)
@@ -8,7 +8,9 @@
  * (C) Copyright 1995 1996 Linus Torvalds
  */
 
-//#include <linux/vmalloc.h>
+#include <xeno/config.h>
+#include <xeno/lib.h>
+#include <xeno/mm.h>
 #include <asm/io.h>
 #include <asm/pgalloc.h>
 #include <asm/page.h>
index 4f198941f5912c2074945a68bfe3719af8901f02..5d387e667763f2578734b3bbb517fc0d9dacd80d 100644 (file)
@@ -36,6 +36,8 @@
 #include <xeno/init.h>
 #include <xeno/interrupt.h>
 #include <xeno/irq.h>
+#include <xeno/mm.h>
+#include <xeno/slab.h>
 #include <asm/pgalloc.h>
 #include <asm/mc146818rtc.h>
 #include <asm/smpboot.h>
index 3fbc6edcae4af41a7db0776bffb5374b1650f68f..8ca6b90ccffc74633c1aa1048033fa92ba7c3924 100644 (file)
@@ -13,6 +13,7 @@
 #include <xeno/sched.h>
 #include <xeno/lib.h>
 #include <xeno/errno.h>
+#include <xeno/mm.h>
 #include <asm/ptrace.h>
 #include <xeno/delay.h>
 #include <xeno/spinlock.h>
index d803c8e5ca6e15ed55881fb5eb7ed7788e57e5f3..3ac6e72c0f3b78dbc6064572bbb6a5fa835ec8c8 100644 (file)
@@ -9,6 +9,7 @@
 #include <xeno/config.h>
 #include <xeno/types.h>
 #include <xeno/lib.h>
+#include <xeno/mm.h>
 #include <xeno/dom0_ops.h>
 #include <xeno/sched.h>
 #include <xeno/event.h>
index 52c4d30f905e6759143240413d1b2cdcfa899a20..0dd7111ac815b048ed381482fe79bd0585c9661f 100644 (file)
@@ -9,6 +9,7 @@
 #include <xeno/config.h>
 #include <xeno/types.h>
 #include <xeno/lib.h>
+#include <xeno/mm.h>
 #include <xeno/dom_mem_ops.h>
 #include <xeno/sched.h>
 #include <xeno/event.h>
index 7e0ba72b7392d20192c6e8a7d10dad604b493556..1f3a2dd406f6dc48d9e97f222ef067062b01efb5 100644 (file)
 #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
 #define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
 
+/* Both these structures are protected by the tasklist_lock. */
 rwlock_t tasklist_lock __cacheline_aligned = RW_LOCK_UNLOCKED;
-
-#define TASK_HASH_SIZE 256
-#define TASK_HASH(_id) ((_id)&(TASK_HASH_SIZE-1))
-static struct task_struct *task_hash[TASK_HASH_SIZE];
+struct task_struct *task_hash[TASK_HASH_SIZE];
 
 /*
  * create a new domain
index 8d569182d3913bac31e90360dfb2525cb52f6b93..4ba43b24f9efdf9f402c4b1e70ecf2cbe61baa36 100644 (file)
@@ -527,10 +527,6 @@ int console_export(char *str, int len)
     ethh->h_proto = htons(ETH_P_IP);
     skb->mac.ethernet= (struct ethhdr *)ethh;
 
-    /* Keep the net rule tables happy. */
-    skb->src_vif = VIF_PHYSICAL_INTERFACE;
-    skb->dst_vif = 0;
-    
     unmap_domain_mem(skb_data);
     
     (void)netif_rx(skb);
index 51c56a8f856940b38c42bd7dd18e18ddb75b26ef..f63f82e4b1004daa4a63bae4707f61ae582ba603 100644 (file)
 #include <asm/domain_page.h>
 #include <asm/io.h>
 
-/* vif globals 
- * sys_vif_list is a lookup table for vifs, used in packet forwarding.
- * it will be replaced later by something a little more flexible.
- */
-
-int sys_vif_count;                                  /* global vif count */
-net_vif_t *sys_vif_list[MAX_SYSTEM_VIFS];           /* global vif array */
 net_rule_ent_t *net_rule_list;                      /* global list of rules */
 kmem_cache_t *net_vif_cache;                        
 kmem_cache_t *net_rule_cache;
 static rwlock_t net_rule_lock = RW_LOCK_UNLOCKED;   /* rule mutex */
 
-rwlock_t sys_vif_lock = RW_LOCK_UNLOCKED;    /* vif mutex */
-
 void print_net_rule_list();
 
 
 /* ----[ VIF Functions ]----------------------------------------------------*/
 
+
+net_vif_t *find_vif_by_id(unsigned long id)
+{
+    struct task_struct *p;
+    net_vif_t *vif = NULL;
+    unsigned long flags, dom = id>>VIF_DOMAIN_SHIFT;
+
+    read_lock_irqsave(&tasklist_lock, flags);
+    p = task_hash[TASK_HASH(dom)];
+    while ( p != NULL )
+    {
+        if ( p->domain == dom )
+        {
+            vif = p->net_vif_list[id&VIF_INDEX_MASK];
+            if ( vif != NULL ) get_vif(vif);
+            break;
+        }
+        p = p->next_hash;
+    }
+    read_unlock_irqrestore(&tasklist_lock, flags);
+
+    return vif;
+}
+
+
 /* create_net_vif - Create a new vif and append it to the specified domain.
  * 
  * the domain is examined to determine how many vifs currently are allocated
@@ -47,7 +63,6 @@ void print_net_rule_list();
  * global list.
  * 
  */
-
 net_vif_t *create_net_vif(int domain)
 {
     int dom_vif_idx;
@@ -59,6 +74,8 @@ net_vif_t *create_net_vif(int domain)
     if ( !(p = find_domain_by_id(domain)) )
         return NULL;
     
+    write_lock_irqsave(&tasklist_lock, flags);
+
     for ( dom_vif_idx = 0; dom_vif_idx < MAX_DOMAIN_VIFS; dom_vif_idx++ )
         if ( p->net_vif_list[dom_vif_idx] == NULL ) break;
     if ( dom_vif_idx == MAX_DOMAIN_VIFS )
@@ -82,20 +99,18 @@ net_vif_t *create_net_vif(int domain)
     new_vif->shared_rings = new_ring;
     new_vif->shared_idxs  = &p->shared_info->net_idx[dom_vif_idx];
     new_vif->domain       = p;
+    new_vif->idx          = dom_vif_idx;
     new_vif->list.next    = NULL;
     spin_lock_init(&new_vif->rx_lock);
     spin_lock_init(&new_vif->tx_lock);
 
     p->net_vif_list[dom_vif_idx] = new_vif;
-
-    write_lock_irqsave(&sys_vif_lock, flags);
-    new_vif->id = sys_vif_count;
-    sys_vif_list[sys_vif_count++] = new_vif;
-    write_unlock_irqrestore(&sys_vif_lock, flags);
     
+    write_unlock_irqrestore(&tasklist_lock, flags);
     return new_vif;
     
  fail:
+    write_unlock_irqrestore(&tasklist_lock, flags);
     if ( new_vif != NULL )
         kmem_cache_free(net_vif_cache, new_vif);
     if ( p != NULL )
@@ -146,32 +161,25 @@ void destroy_net_vif(net_vif_t *vif)
 void unlink_net_vif(net_vif_t *vif)
 {
     unsigned long flags;
-    int i;
 
     if ( vif == NULL )
         return;
 
-    for ( i = 0; i < MAX_DOMAIN_VIFS; i++ )
-        if ( vif->domain->net_vif_list[i] == vif )
-            vif->domain->net_vif_list[i] = NULL;
-    
-    write_lock_irqsave(&sys_vif_lock, flags);
-    sys_vif_list[vif->id] = NULL;
-    write_unlock_irqrestore(&sys_vif_lock, flags);
-    
+    write_lock_irqsave(&tasklist_lock, flags);
+    vif->domain->net_vif_list[vif->idx] = NULL;
+    write_unlock_irqrestore(&tasklist_lock, flags);
+
     put_vif(vif);
 }
 
 
-/* vif_query - Call from the proc file system to get a list of vifs 
- * assigned to a particular domain.
+/* vif_query - Call from the proc file system to get a list of indexes
+ * in use by a particular domain.
  */
-
 void vif_query(vif_query_t *vq)
 {
     net_vif_t *vif;
     struct task_struct *p;
-    unsigned long flags;
     char buf[128];
     int i;
 
@@ -180,14 +188,12 @@ void vif_query(vif_query_t *vq)
 
     *buf = '\0';
 
-    read_lock_irqsave(&sys_vif_lock, flags);
-    for ( i = 0; i < MAX_SYSTEM_VIFS; i++ )
+    for ( i = 0; i < MAX_DOMAIN_VIFS; i++ )
     {
-        vif = sys_vif_list[i];
-        if ( (vif == NULL) || (vif->domain != p) ) continue;
-        sprintf(buf + strlen(buf), "%d\n", vif->id);
+        vif = p->net_vif_list[i];
+        if ( vif == NULL ) continue;
+        sprintf(buf + strlen(buf), "%d\n", i);
     }
-    read_unlock_irqrestore(&sys_vif_lock, flags);
 
     copy_to_user(vq->buf, buf, strlen(buf) + 1);
     
@@ -204,9 +210,7 @@ int add_net_rule(net_rule_t *rule)
     net_rule_ent_t *new_ent;
     
     if ( (new_ent = kmem_cache_alloc(net_rule_cache, GFP_KERNEL)) == NULL )
-    {
         return -ENOMEM;
-    }
 
     memcpy(&new_ent->r, rule, sizeof(net_rule_t));
 
@@ -253,7 +257,7 @@ int delete_net_rule(net_rule_t *rule)
  * ip address to the specified vif.  It's used to set up domain zero.
  */
 
-void add_default_net_rule(int vif_id, u32 ipaddr)
+void add_default_net_rule(unsigned long vif_id, u32 ipaddr)
 {
     net_rule_t new_rule;
 
@@ -261,8 +265,8 @@ void add_default_net_rule(int vif_id, u32 ipaddr)
     memset(&new_rule, 0, sizeof(net_rule_t));
     new_rule.src_addr = ipaddr;
     new_rule.src_addr_mask = 0xffffffff;
-    new_rule.src_interface = vif_id;
-    new_rule.dst_interface = VIF_PHYSICAL_INTERFACE;
+    new_rule.src_vif = vif_id;
+    new_rule.dst_vif = VIF_PHYSICAL_INTERFACE;
     new_rule.action = NETWORK_ACTION_ACCEPT;
     new_rule.proto = NETWORK_PROTO_ANY;
     add_net_rule(&new_rule);
@@ -271,8 +275,8 @@ void add_default_net_rule(int vif_id, u32 ipaddr)
     memset(&new_rule, 0, sizeof(net_rule_t));
     new_rule.dst_addr = ipaddr;
     new_rule.dst_addr_mask = 0xffffffff;
-    new_rule.src_interface = VIF_ANY_INTERFACE;
-    new_rule.dst_interface = vif_id;
+    new_rule.src_vif = VIF_ANY_INTERFACE;
+    new_rule.dst_vif = vif_id;
     new_rule.action = NETWORK_ACTION_ACCEPT;
     new_rule.proto = NETWORK_PROTO_ANY;
     add_net_rule(&new_rule);
@@ -294,8 +298,32 @@ void print_net_rule(net_rule_t *r)
     printk("=] dst_port         : %u\n", r->dst_port);
     printk("=] dst_port_mask    : %u\n", r->dst_port_mask);
     printk("=] dst_proto        : %u\n", r->proto);
-    printk("=] src_interface    : %d\n", r->src_interface);
-    printk("=] dst_interface    : %d\n", r->dst_interface);
+    switch ( r->src_vif )
+    {
+    case VIF_PHYSICAL_INTERFACE:
+        printk("=] src_dom/idx      : PHYSICAL\n"); 
+        break;
+    case VIF_ANY_INTERFACE:
+        printk("=] src_dom/idx      : ANY\n"); 
+        break;
+    default:
+        printk("=] src_dom/idx      : %lu/%lu\n", 
+               r->src_vif>>VIF_DOMAIN_SHIFT, r->src_vif&VIF_INDEX_MASK);
+        break;
+    }
+    switch ( r->dst_vif )
+    {
+    case VIF_PHYSICAL_INTERFACE:
+        printk("=] dst_dom/idx      : PHYSICAL\n"); 
+        break;
+    case VIF_ANY_INTERFACE:
+        printk("=] dst_dom/idx      : ANY\n"); 
+        break;
+    default:
+        printk("=] dst_dom/idx      : %lu/%lu\n", 
+               r->dst_vif>>VIF_DOMAIN_SHIFT, r->dst_vif&VIF_INDEX_MASK);
+        break;
+    }
     printk("=] action           : %u\n", r->action);
 }
 
@@ -327,20 +355,21 @@ void print_net_rule_list()
  * Apply the rules to this skbuff and return the vif id that it is bound for.
  * If there is no match, VIF_DROP is returned.
  */
-int net_find_rule(u8 nproto, u8 tproto, u32 src_addr, u32 dst_addr, 
-                  u16 src_port, u16 dst_port, int src_vif)
+static net_vif_t *net_find_rule(u8 nproto, u8 tproto, u32 src_addr, 
+                                u32 dst_addr, u16 src_port, 
+                                u16 dst_port, unsigned long src_vif)
 {
     net_rule_ent_t *ent;
-    int dest = VIF_DROP;
-    
+    unsigned long dest = VIF_UNKNOWN_INTERFACE;
+
     read_lock(&net_rule_lock);
     
     ent = net_rule_list;
     
     while ( ent != NULL )
     {
-        if ( ((ent->r.src_interface == src_vif)
-              || (ent->r.src_interface == VIF_ANY_INTERFACE)) &&
+        if ( ((ent->r.src_vif == src_vif)
+              || (ent->r.src_vif == VIF_ANY_INTERFACE)) &&
 
              (!((ent->r.src_addr ^ src_addr) & ent->r.src_addr_mask )) &&
              (!((ent->r.dst_addr ^ dst_addr) & ent->r.dst_addr_mask )) &&
@@ -361,18 +390,24 @@ int net_find_rule(u8 nproto, u8 tproto, u32 src_addr, u32 dst_addr,
             /*
              * XXX FFS! We keep going to find the "best" rule. Where best 
              * corresponds to vaguely sane routing of a packet. We need a less 
-             * shafted model for aour "virtual firewall/router" methinks!
+             * shafted model for our "virtual firewall/router" methinks!
              */
-            if ( dest < 0 )
-                dest = ent->r.dst_interface;
-            if ( dest >= 0 )
+            if ( (dest & VIF_DOMAIN_MASK) == VIF_SPECIAL )
+                dest = ent->r.dst_vif;
+            if ( (dest & VIF_DOMAIN_MASK) != VIF_SPECIAL )
                 break;
         }
         ent = ent->next;
     }
 
     read_unlock(&net_rule_lock);
-    return dest;
+
+    if ( dest == VIF_PHYSICAL_INTERFACE )
+        return VIF_PHYS;
+    else if ( (dest & VIF_DOMAIN_MASK) == VIF_SPECIAL )
+        return VIF_DROP;
+    else
+        return find_vif_by_id(dest);
 }
 
 /* net_get_target_vif - Find the vif that the given sk_buff is bound for.
@@ -393,14 +428,16 @@ int net_find_rule(u8 nproto, u8 tproto, u32 src_addr, u32 dst_addr,
  * based on the packet type.  it then calls net_find_rule to scan the rule 
  * list.
  */
-
-#define net_get_target_vif(skb) __net_get_target_vif(skb->data, skb->len, skb->src_vif)
-
-int __net_get_target_vif(u8 *data, unsigned int len, int src_vif)
+net_vif_t *net_get_target_vif(u8 *data, unsigned int len, net_vif_t *src_vif)
 {
-    int target = VIF_DROP;
+    net_vif_t *target = VIF_DROP;
     u8 *h_raw, *nh_raw;
-    
+    unsigned long src_vif_val = VIF_PHYSICAL_INTERFACE;
+
+    if ( src_vif != VIF_PHYS )
+        src_vif_val = (src_vif->domain->domain<<VIF_DOMAIN_SHIFT) | 
+            src_vif->idx;
+
     if ( len < ETH_HLEN ) goto drop;
 
     nh_raw = data + ETH_HLEN;
@@ -410,34 +447,26 @@ int __net_get_target_vif(u8 *data, unsigned int len, int src_vif)
         if ( len < (ETH_HLEN + 28) ) goto drop;
         target = net_find_rule((u8)ETH_P_ARP, 0, ntohl(*(u32 *)(nh_raw + 14)),
                                ntohl(*(u32 *)(nh_raw + 24)), 0, 0, 
-                               src_vif);
+                               src_vif_val);
         break;
 
     case ETH_P_IP:
         if ( len < (ETH_HLEN + 20) ) goto drop;
         h_raw =  data + ((*(unsigned char *)(nh_raw)) & 0x0f) * 4;
-        
-        /* XXX For now, we ignore ports. */
-#if 0
-        target = net_find_rule((u8)ETH_P_IP,  *(u8 *)(nh_raw + 9),
-                               ntohl(*(u32 *)(nh_raw + 12)),
-                               ntohl(*(u32 *)(nh_raw + 16)),
-                               ntohs(*(u16 *)(h_raw)),
-                               ntohs(*(u16 *)(h_raw + 2)), 
-                               src_vif);
-#else
+        /* NB. For now we ignore ports. */
         target = net_find_rule((u8)ETH_P_IP,  *(u8 *)(data + 9),
                                ntohl(*(u32 *)(nh_raw + 12)),
                                ntohl(*(u32 *)(nh_raw + 16)),
                                0,
                                0, 
-                               src_vif);
-#endif
+                               src_vif_val);
+        break;
     }
     return target;
     
  drop:
-    printk("VIF%d: pkt to drop!\n", src_vif);
+    printk("VIF%lu/%lu: pkt to drop!\n", 
+           src_vif_val>>VIF_DOMAIN_SHIFT, src_vif_val&VIF_INDEX_MASK);
     return VIF_DROP;
 }
 
@@ -496,8 +525,6 @@ long do_network_op(network_op_t *u_network_op)
 
 void __init net_init (void)
 {
-    sys_vif_count = 0;
-    memset(sys_vif_list, 0, sizeof(sys_vif_list));
     net_rule_list = NULL;
     net_vif_cache = kmem_cache_create("net_vif_cache", sizeof(net_vif_t),
                                     0, SLAB_HWCACHE_ALIGN, NULL, NULL);
index 303dba32bad6740145d5dd200784eebdcf18f5a4..434af2d00ab026d61fed2e5547527ddc522c03e9 100644 (file)
@@ -28,7 +28,7 @@
 #include <xeno/time.h>
 #include <xeno/ac_timer.h>
 #include <xeno/interrupt.h>
-
+#include <xeno/timer.h>
 #include <xeno/perfc.h>
 
 
index 5629eac6373ed36dfa62ba263c4a4b99abbb8c28..ebcf9fedfb94c45ff835eae60b5873783b089e6a 100644 (file)
@@ -17,6 +17,7 @@
 #include <xeno/keyhandler.h>
 #include <xeno/interrupt.h>
 #include <xeno/segment.h>
+#include <xeno/slab.h>
 
 #if 0
 #define DPRINTK(_f, _a...) printk( _f , ## _a )
index fc39615fc75135a7e5c7cbcd8e0cd903494b7c51..b6970238ebadb1528c6ea9cb1b7ac80d3fd5b15b 100644 (file)
@@ -16,7 +16,7 @@
 #define _SCSI_H
 
 #include <xeno/config.h>       /* for CONFIG_SCSI_LOGGING */
-/*#include <xeno/devfs_fs_kernel.h>*/
+#include <xeno/timer.h>
 /*#include <xeno/proc_fs.h>*/
 
 /*
index 2de090ab6239856762f6043171b1de54957cd4c5..fa8a365f217f682ecbd4772169659cf67aa771d5 100644 (file)
@@ -104,12 +104,22 @@ typedef struct net_rule_st
     u16  src_port_mask;
     u16  dst_port_mask;
     u16  proto;
-    
-    int  src_interface;
-    int  dst_interface;
+    unsigned long src_vif;
+    unsigned long dst_vif;
     u16  action;
 } net_rule_t;
 
+#define VIF_DOMAIN_MASK  0xfffff000UL
+#define VIF_DOMAIN_SHIFT 12
+#define VIF_INDEX_MASK   0x00000fffUL
+#define VIF_INDEX_SHIFT  0
+
+/* These are specified in the index if the dom is SPECIAL. */
+#define VIF_SPECIAL      0xfffff000UL
+#define VIF_UNKNOWN_INTERFACE   (VIF_SPECIAL | 0)
+#define VIF_PHYSICAL_INTERFACE  (VIF_SPECIAL | 1)
+#define VIF_ANY_INTERFACE       (VIF_SPECIAL | 2)
+
 typedef struct vif_query_st
 {
     unsigned int    domain;
index a23fd2d93c42f06dafac6a9f53213d9abfeda8be..ca28a6a14161e1874d23ecc219ed1b929704373d 100644 (file)
@@ -7,6 +7,7 @@
 #include <xeno/list.h>
 #include <xeno/kdev_t.h>
 #include <xeno/sched.h>
+#include <xeno/mm.h>
 
 /* Some defines from fs.h that may actually be useful to the blkdev layer. */
 #define READ 0
index dacfd89842e1d16cdf494b9d3d1438cbc5694e18..0dfa790013af00d8c594df8530ab373795679d5e 100644 (file)
@@ -13,7 +13,7 @@
 #include <xeno/hdsmart.h>
 #include <xeno/major.h>
 #include <xeno/blkdev.h>
-/*#include <xeno/proc_fs.h>*/
+#include <xeno/timer.h>
 /*#include <xeno/devfs_fs_kernel.h>*/
 #include <asm/hdreg.h>
 
index 323c201d9359ed70ffaf9f6b3a4402d1c1c30332..51b0b52d154ffca3e505bba9901e9c3b747c7553 100644 (file)
@@ -267,6 +267,11 @@ void domain_init(void);
 int idle_cpu(int cpu); /* Is CPU 'cpu' idle right now? */
 void cpu_idle(void);   /* Idle loop. */
 
+/* This hash table is protected by the tasklist_lock. */
+#define TASK_HASH_SIZE 256
+#define TASK_HASH(_id) ((_id)&(TASK_HASH_SIZE-1))
+struct task_struct *task_hash[TASK_HASH_SIZE];
+
 #define REMOVE_LINKS(p) do { \
         (p)->next_task->prev_task = (p)->prev_task; \
         (p)->prev_task->next_task = (p)->next_task; \
index 519328a679db19cf05544bc4783061a648d96343..367a7c114e6837da18d88df2aeaa680ac7219edd 100644 (file)
 #include <asm/types.h>
 #include <linux/spinlock.h>
 #include <linux/mm.h>
-
-/* vif special values */
-#define VIF_PHYSICAL_INTERFACE  -1
-#define VIF_UNKNOWN_INTERFACE   -2
-#define VIF_DROP                -3
-#define VIF_ANY_INTERFACE       -4
+#include <xeno/vif.h>
 
 /* skb_type values */
 #define SKB_NORMAL               0 /* A Linux-style skbuff: no strangeness */
@@ -162,8 +157,8 @@ struct sk_buff {
 
     void               (*destructor)(struct sk_buff *);        /* Destruct function            */
     struct pfn_info *pf;                    /* record of physical pf address for freeing    */
-    int src_vif;                            /* vif we came from                             */
-    int dst_vif;                            /* vif we are bound for                         */
+    net_vif_t *src_vif;                     /* vif we came from                             */
+    net_vif_t *dst_vif;                     /* vif we are bound for                         */
     struct skb_shared_info shinfo;          /* shared info is no longer shared in Xen.      */
 };
 
index ac5e1f35a1ba4b484da9b183feb44af3aaad0924..de83e7e76ba8517a4dabde9d6c0b07b5af79244d 100644 (file)
@@ -6,6 +6,9 @@
  * Copyright (c) 2002-2003, A K Warfield and K A Fraser
  */
 
+#ifndef __XENO_VIF_H__
+#define __XENO_VIF_H__
+
 /* virtual network interface struct and associated defines. */
 /* net_vif_st is the larger struct that describes a virtual network interface
  * it contains a pointer to the net_ring_t structure that needs to be on a 
@@ -16,7 +19,6 @@
  */
 
 #include <hypervisor-ifs/network.h>
-#include <xeno/skbuff.h>
 
 /* 
  * shadow ring structures are used to protect the descriptors from
@@ -62,8 +64,8 @@ typedef struct net_vif_st {
     unsigned int tx_resp_prod; /* private version of shared variable */
 
     /* Miscellaneous private stuff. */
-    int                 id;
     struct task_struct *domain;
+    unsigned int idx; /* index within domain */
     struct list_head    list;     /* scheduling list */
     atomic_t            refcnt;
     spinlock_t          rx_lock, tx_lock;
@@ -75,24 +77,22 @@ do {                                                               \
     if ( atomic_dec_and_test(&(_v)->refcnt) ) destroy_net_vif(_v); \
 } while (0)                                                        \
 
-/* VIF-related defines. */
-#define MAX_SYSTEM_VIFS 256  
-
-/* vif globals */
-extern int sys_vif_count;
-extern net_vif_t *sys_vif_list[];
-extern rwlock_t sys_vif_lock; /* protects the sys_vif_list */
-
 /* vif prototypes */
 net_vif_t *create_net_vif(int domain);
 void destroy_net_vif(net_vif_t *vif);
 void unlink_net_vif(net_vif_t *vif);
-void add_default_net_rule(int vif_id, u32 ipaddr);
-int __net_get_target_vif(u8 *data, unsigned int len, int src_vif);
-void add_default_net_rule(int vif_id, u32 ipaddr);
-
-#define net_get_target_vif(skb) __net_get_target_vif(skb->data, skb->len, skb->src_vif)
-/* status fields per-descriptor:
+void add_default_net_rule(unsigned long vif_id, u32 ipaddr);
+net_vif_t *net_get_target_vif(u8 *data, unsigned int len, net_vif_t *src_vif);
+net_vif_t *find_vif_by_id(unsigned long id);
+
+/*
+ * Return values from net_get_target_vif:
+ *  VIF_PHYS -- Send to physical NIC
+ *  VIF_DROP -- Drop this packet
+ *  others   -- Send to specified VIF (reference held on return)
  */
+#define VIF_PHYS ((net_vif_t *)0)
+#define VIF_DROP ((net_vif_t *)1)
 
+#endif /* __XENO_VIF_H__ */
 
index 846a9e13d1f2d45fd830d588311684e00af5c687..87144aa1622ea6748cd5421ef6567bbfa8182fc6 100644 (file)
@@ -586,7 +586,6 @@ int netif_rx(struct sk_buff *skb)
 {
     int offset, this_cpu = smp_processor_id();
     unsigned long flags;
-    net_vif_t *vif;
 
     local_irq_save(flags);
 
@@ -605,17 +604,11 @@ int netif_rx(struct sk_buff *skb)
 
     netdev_rx_stat[this_cpu].total++;
 
-    if ( skb->src_vif == VIF_UNKNOWN_INTERFACE )
-        skb->src_vif = VIF_PHYSICAL_INTERFACE;
-                
-    if ( skb->dst_vif == VIF_UNKNOWN_INTERFACE )
-        skb->dst_vif = __net_get_target_vif(skb->data, skb->len, skb->src_vif);
+    if ( skb->dst_vif == NULL )
+        skb->dst_vif = net_get_target_vif(skb->data, skb->len, skb->src_vif);
         
-    read_lock(&sys_vif_lock);
-    if ( (skb->dst_vif <= VIF_PHYSICAL_INTERFACE) ||
-         ((vif = sys_vif_list[skb->dst_vif]) == NULL) )
+    if ( (skb->dst_vif == VIF_PHYS) || (skb->dst_vif == VIF_DROP) )
     {
-        read_unlock(&sys_vif_lock);
         netdev_rx_stat[this_cpu].dropped++;
         unmap_domain_mem(skb->head);
         kfree_skb(skb);
@@ -623,10 +616,8 @@ int netif_rx(struct sk_buff *skb)
         return NET_RX_DROP;
     }
 
-    get_vif(vif);
-    read_unlock(&sys_vif_lock);
-    deliver_packet(skb, vif);
-    put_vif(vif);
+    deliver_packet(skb, skb->dst_vif);
+    put_vif(skb->dst_vif);
 
     unmap_domain_mem(skb->head);
     kfree_skb(skb);
@@ -690,7 +681,7 @@ static void add_to_net_schedule_list_tail(net_vif_t *vif)
 static void tx_skb_release(struct sk_buff *skb)
 {
     int i;
-    net_vif_t *vif = sys_vif_list[skb->src_vif];
+    net_vif_t *vif = skb->src_vif;
     tx_shadow_entry_t *tx;
     unsigned long flags;
     
@@ -755,8 +746,8 @@ static void net_tx_action(unsigned long unused)
         skb->end  = skb->tail = skb->head + PKT_PROT_LEN;
         
         skb->dev      = the_dev;
-        skb->src_vif  = vif->id;
-        skb->dst_vif  = VIF_PHYSICAL_INTERFACE;
+        skb->src_vif  = vif;
+        skb->dst_vif  = NULL;
         skb->mac.raw  = skb->data; 
         
         skb_shinfo(skb)->frags[0].page        = frame_table +
@@ -1765,7 +1756,7 @@ long do_net_update(void)
     unsigned long pte_pfn, buf_pfn;
     struct pfn_info *pte_page, *buf_page;
     unsigned long *ptep;    
-    int target;
+    net_vif_t *target;
     u8 *g_data;
     unsigned short protocol;
 
@@ -1792,7 +1783,8 @@ long do_net_update(void)
                   (((vif->tx_resp_prod-i) & (TX_RING_SIZE-1)) != 1); 
               i = TX_RING_INC(i) )
         {
-            tx = shared_rings->tx_ring[i].req;
+            tx     = shared_rings->tx_ring[i].req;
+            target = VIF_DROP;
 
             if ( (tx.size < PKT_PROT_LEN) || (tx.size > ETH_FRAME_LEN) )
             {
@@ -1832,18 +1824,36 @@ long do_net_update(void)
                 goto tx_unmap_and_continue;
             }
 
-            target = __net_get_target_vif(g_data, tx.size, vif->id);
+            target = net_get_target_vif(g_data, tx.size, vif);
 
-            if ( target > VIF_PHYSICAL_INTERFACE )
+            if ( target == VIF_PHYS )
+            {
+                vif->tx_shadow_ring[j].id     = tx.id;
+                vif->tx_shadow_ring[j].size   = tx.size;
+                vif->tx_shadow_ring[j].header = 
+                    kmem_cache_alloc(net_header_cachep, GFP_KERNEL);
+                if ( vif->tx_shadow_ring[j].header == NULL )
+                { 
+                    make_tx_response(vif, tx.id, RING_STATUS_OK);
+                    goto tx_unmap_and_continue;
+                }
+
+                memcpy(vif->tx_shadow_ring[j].header, g_data, PKT_PROT_LEN);
+                vif->tx_shadow_ring[j].payload = tx.addr + PKT_PROT_LEN;
+                get_page_tot(buf_page);
+                j = TX_RING_INC(j);
+            }
+            else if ( target != VIF_DROP )
             {
                 /* Local delivery */
                 if ( (skb = dev_alloc_skb(ETH_FRAME_LEN + 32)) == NULL )
                 {
                     make_tx_response(vif, tx.id, RING_STATUS_BAD_PAGE);
+                    put_vif(target);
                     goto tx_unmap_and_continue;
                 }
 
-                skb->src_vif = vif->id;
+                skb->src_vif = vif;
                 skb->dst_vif = target;
                 skb->protocol = protocol;                
 
@@ -1865,23 +1875,6 @@ long do_net_update(void)
 
                 make_tx_response(vif, tx.id, RING_STATUS_OK);
             }
-            else if ( target == VIF_PHYSICAL_INTERFACE )
-            {
-                vif->tx_shadow_ring[j].id     = tx.id;
-                vif->tx_shadow_ring[j].size   = tx.size;
-                vif->tx_shadow_ring[j].header = 
-                    kmem_cache_alloc(net_header_cachep, GFP_KERNEL);
-                if ( vif->tx_shadow_ring[j].header == NULL )
-                { 
-                    make_tx_response(vif, tx.id, RING_STATUS_OK);
-                    goto tx_unmap_and_continue;
-                }
-
-                memcpy(vif->tx_shadow_ring[j].header, g_data, PKT_PROT_LEN);
-                vif->tx_shadow_ring[j].payload = tx.addr + PKT_PROT_LEN;
-                get_page_tot(buf_page);
-                j = TX_RING_INC(j);
-            }
 
         tx_unmap_and_continue:
             unmap_domain_mem(g_data);
index 16937fa0826ee2baceef4f4c50ab648f86424ab3..cf60a573a96e5685bae77cf25036c0cd40521b68 100644 (file)
@@ -222,8 +222,6 @@ struct sk_buff *alloc_skb(unsigned int size,int gfp_mask)
     /* Set up other state */
     skb->len = 0;
     skb->data_len = 0;
-    skb->src_vif = VIF_UNKNOWN_INTERFACE;
-    skb->dst_vif = VIF_UNKNOWN_INTERFACE;
     skb->skb_type = SKB_NORMAL;
 
     skb_shinfo(skb)->nr_frags = 0;
@@ -270,8 +268,6 @@ struct sk_buff *alloc_zc_skb(unsigned int size,int gfp_mask)
     /* Set up other state */
     skb->len = 0;
     skb->data_len = 0;
-    skb->src_vif = VIF_UNKNOWN_INTERFACE;
-    skb->dst_vif = VIF_UNKNOWN_INTERFACE;
     skb->skb_type = SKB_ZERO_COPY;
 
     skb_shinfo(skb)->nr_frags = 0;
@@ -312,6 +308,8 @@ static inline void skb_headerinit(void *p, kmem_cache_t *cache,
 {
     struct sk_buff *skb = p;
 
+    skb->src_vif = NULL;
+    skb->dst_vif = NULL;
     skb->next = NULL;
     skb->prev = NULL;
     skb->list = NULL;
index c36ab02e96da9a410153b559a57e673fe4e10a51..d3e4752eb388efb511d25d5b9b2f336658d283e7 100644 (file)
@@ -75,15 +75,11 @@ static int cmd_read_proc(char *page, char **start, off_t off,
 
 static ssize_t dom_vif_read(struct file * file, char * buff, size_t size, loff_t * off)
 {
-    char hyp_buf[128]; // Hypervisor is going to write its reply here.
+    char hyp_buf[128];
     network_op_t op;
     static int finished = 0;
 
-    // This seems to be the only way to make the OS stop making read requests
-    // to the file.  When we use the fileoperations version of read, offset 
-    // seems to be ignored altogether.
-    
-    if (finished) 
+    if ( finished ) 
     {
         finished = 0;
         return 0;
index 13fe25ec9c8eb5dd73eeec1fe1fb1dfcf1064a98..852f6943e24138f2b8e9d76cd1714033a78c57f3 100644 (file)
@@ -26,7 +26,7 @@ u16 antous(const char *buff, int len);
 int anton(const char *buff, int len);
 
 static int vfr_read_proc(char *page, char **start, off_t off,
-                                          int count, int *eof, void *data)
+                         int count, int *eof, void *data)
 {   
     strcpy(page, readbuf);
     *readbuf = '\0';
@@ -60,147 +60,163 @@ static int vfr_read_proc(char *page, char **start, off_t off,
                      ((_x)=='\f') || ((_x)=='\r') || ((_x)=='\n') )
 
 static int vfr_write_proc(struct file *file, const char *buffer,
-                                           u_long count, void *data)
+                          u_long count, void *data)
 {
-  network_op_t op;
-  int ret, len;
-  int ts, te, tl; // token start, end, and length
-  int fs, fe, fl; // field.
-
-  len = count;
-  ts = te = 0;
-
-  memset(&op, 0, sizeof(network_op_t));
-
-  // get the command:
-  while ( count && isspace(buffer[ts]) ) { ts++; count--; } // skip spaces.
-  te = ts;
-  while ( count && !isspace(buffer[te]) ) { te++; count--; } // command end
-  if ( te <= ts ) goto bad;
-  tl = te - ts;
-  
-  if ( strncmp(&buffer[ts], "ADD", tl) == 0 )
-  {
-     op.cmd = NETWORK_OP_ADDRULE;
-  }
-  else if ( strncmp(&buffer[ts], "DELETE", tl) == 0 )
-  {
-     op.cmd = NETWORK_OP_DELETERULE;
-  }
-  else if ( strncmp(&buffer[ts], "PRINT", tl) == 0 )
-  {
-     op.cmd = NETWORK_OP_GETRULELIST;
-     goto doneparsing;
-  }
-        
-  ts = te;
-  
-  // get the action
-  while ( count && (buffer[ts] == ' ') ) { ts++; count--; } // skip spaces.
-  te = ts;
-  while ( count && (buffer[te] != ' ') ) { te++; count--; } // command end
-  if ( te <= ts ) goto bad;
-  tl = te - ts;
-
-  if ( strncmp(&buffer[ts], "ACCEPT", tl) == 0 ) 
-  {
-    op.u.net_rule.action = NETWORK_ACTION_ACCEPT;
-    goto keyval;
-  }
-  if ( strncmp(&buffer[ts], "COUNT", tl) == 0 ) 
-  {
-    op.u.net_rule.action = NETWORK_ACTION_COUNT;
-    goto keyval;
-  }
-   
-  // default case;
-  return (len);
-  
+    network_op_t op;
+    int ret, len;
+    int ts, te, tl; // token start, end, and length
+    int fs, fe, fl; // field.
 
-  // get the key=val pairs.
- keyval:
-  while (count)
-  {
-    //get field
-    ts = te; while ( count && isspace(buffer[ts]) ) { ts++; count--; }
-    te = ts;
-    while ( count && !isspace(buffer[te]) && (buffer[te] != '=') ) 
-      { te++; count--; }
-    if ( te <= ts )
-       goto doneparsing;
-    tl = te - ts;
-    fs = ts; fe = te; fl = tl; // save the field markers.
-    // skip "   =   " (ignores extra equals.)
-    while ( count && (isspace(buffer[te]) || (buffer[te] == '=')) ) 
-      { te++; count--; }
-    ts = te;
-    while ( count && !isspace(buffer[te]) ) { te++; count--; }
-    tl = te - ts;
+    len = count;
+    ts = te = 0;
 
-    if ( (fl <= 0) || (tl <= 0) ) goto bad;
+    memset(&op, 0, sizeof(network_op_t));
 
-    if (strncmp(&buffer[fs], "srcaddr", fl) == 0) 
-    {  
-      op.u.net_rule.src_addr = getipaddr(&buffer[ts], tl);
-    }
-    else if (strncmp(&buffer[fs], "dstaddr", fl) == 0)
-    {    
-      op.u.net_rule.dst_addr = getipaddr(&buffer[ts], tl);
-    }
-    else if (strncmp(&buffer[fs], "srcaddrmask", fl) == 0) 
-    {
-      op.u.net_rule.src_addr_mask = getipaddr(&buffer[ts], tl);
-    }
-    else if (strncmp(&buffer[fs], "dstaddrmask", fl) == 0)
-    {
-      op.u.net_rule.dst_addr_mask = getipaddr(&buffer[ts], tl);
-    }
-    else if (strncmp(&buffer[fs], "srcport", fl) == 0)
+    // get the command:
+    while ( count && isspace(buffer[ts]) ) { ts++; count--; } // skip spaces.
+    te = ts;
+    while ( count && !isspace(buffer[te]) ) { te++; count--; } // command end
+    if ( te <= ts ) goto bad;
+    tl = te - ts;
+  
+    if ( strncmp(&buffer[ts], "ADD", tl) == 0 )
     {
-      op.u.net_rule.src_port = antous(&buffer[ts], tl);
+        op.cmd = NETWORK_OP_ADDRULE;
     }
-    else if (strncmp(&buffer[fs], "dstport", fl) == 0)
+    else if ( strncmp(&buffer[ts], "DELETE", tl) == 0 )
     {
-      op.u.net_rule.dst_port = antous(&buffer[ts], tl);
+        op.cmd = NETWORK_OP_DELETERULE;
     }
-    else if (strncmp(&buffer[fs], "srcportmask", fl) == 0)
+    else if ( strncmp(&buffer[ts], "PRINT", tl) == 0 )
     {
-      op.u.net_rule.src_port_mask = antous(&buffer[ts], tl);
+        op.cmd = NETWORK_OP_GETRULELIST;
+        goto doneparsing;
     }
-    else if (strncmp(&buffer[fs], "dstportmask", fl) == 0)
+        
+    ts = te;
+  
+    // get the action
+    while ( count && (buffer[ts] == ' ') ) { ts++; count--; } // skip spaces.
+    te = ts;
+    while ( count && (buffer[te] != ' ') ) { te++; count--; } // command end
+    if ( te <= ts ) goto bad;
+    tl = te - ts;
+
+    if ( strncmp(&buffer[ts], "ACCEPT", tl) == 0 ) 
     {
-      op.u.net_rule.dst_port_mask = antous(&buffer[ts], tl);
+        op.u.net_rule.action = NETWORK_ACTION_ACCEPT;
+        goto keyval;
     }
-    else if (strncmp(&buffer[fs], "srcint", fl) == 0)
+    if ( strncmp(&buffer[ts], "COUNT", tl) == 0 ) 
     {
-      op.u.net_rule.src_interface = anton(&buffer[ts], tl);
+        op.u.net_rule.action = NETWORK_ACTION_COUNT;
+        goto keyval;
     }
-    else if (strncmp(&buffer[fs], "dstint", fl) == 0)
+   
+    // default case;
+    return (len);
+  
+
+    // get the key=val pairs.
+ keyval:
+    while (count)
     {
-      op.u.net_rule.dst_interface = anton(&buffer[ts], tl);
-    }
-    else if ( (strncmp(&buffer[fs], "proto", fl) == 0))
-    {  
-      if (strncmp(&buffer[ts], "any", tl) == 0) 
-         op.u.net_rule.proto = NETWORK_PROTO_ANY; 
-      if (strncmp(&buffer[ts], "ip", tl) == 0)
-         op.u.net_rule.proto = NETWORK_PROTO_IP;
-      if (strncmp(&buffer[ts], "tcp", tl) == 0) 
-         op.u.net_rule.proto = NETWORK_PROTO_TCP;
-      if (strncmp(&buffer[ts], "udp", tl) == 0)
-         op.u.net_rule.proto = NETWORK_PROTO_UDP;
-      if (strncmp(&buffer[ts], "arp", tl) == 0)
-         op.u.net_rule.proto = NETWORK_PROTO_ARP;
-      
+        //get field
+        ts = te; while ( count && isspace(buffer[ts]) ) { ts++; count--; }
+        te = ts;
+        while ( count && !isspace(buffer[te]) && (buffer[te] != '=') ) 
+        { te++; count--; }
+        if ( te <= ts )
+            goto doneparsing;
+        tl = te - ts;
+        fs = ts; fe = te; fl = tl; // save the field markers.
+        // skip "   =   " (ignores extra equals.)
+        while ( count && (isspace(buffer[te]) || (buffer[te] == '=')) ) 
+        { te++; count--; }
+        ts = te;
+        while ( count && !isspace(buffer[te]) ) { te++; count--; }
+        tl = te - ts;
+
+        if ( (fl <= 0) || (tl <= 0) ) goto bad;
+
+        /* NB. Prefix matches must go first! */
+        if (strncmp(&buffer[fs], "src", fl) == 0)
+        {
+            op.u.net_rule.src_vif = VIF_ANY_INTERFACE;
+        }
+        else if (strncmp(&buffer[fs], "dst", fl) == 0)
+        {
+            op.u.net_rule.dst_vif = VIF_PHYSICAL_INTERFACE;
+        }
+        else if (strncmp(&buffer[fs], "srcaddr", fl) == 0) 
+        {  
+            op.u.net_rule.src_addr = getipaddr(&buffer[ts], tl);
+        }
+        else if (strncmp(&buffer[fs], "dstaddr", fl) == 0)
+        {    
+            op.u.net_rule.dst_addr = getipaddr(&buffer[ts], tl);
+        }
+        else if (strncmp(&buffer[fs], "srcaddrmask", fl) == 0) 
+        {
+            op.u.net_rule.src_addr_mask = getipaddr(&buffer[ts], tl);
+        }
+        else if (strncmp(&buffer[fs], "dstaddrmask", fl) == 0)
+        {
+            op.u.net_rule.dst_addr_mask = getipaddr(&buffer[ts], tl);
+        }
+        else if (strncmp(&buffer[fs], "srcport", fl) == 0)
+        {
+            op.u.net_rule.src_port = antous(&buffer[ts], tl);
+        }
+        else if (strncmp(&buffer[fs], "dstport", fl) == 0)
+        {
+            op.u.net_rule.dst_port = antous(&buffer[ts], tl);
+        }
+        else if (strncmp(&buffer[fs], "srcportmask", fl) == 0)
+        {
+            op.u.net_rule.src_port_mask = antous(&buffer[ts], tl);
+        }
+        else if (strncmp(&buffer[fs], "dstportmask", fl) == 0)
+        {
+            op.u.net_rule.dst_port_mask = antous(&buffer[ts], tl);
+        }
+        else if (strncmp(&buffer[fs], "srcdom", fl) == 0)
+        {
+            op.u.net_rule.src_vif |= anton(&buffer[ts], tl)<<VIF_DOMAIN_SHIFT;
+        }
+        else if (strncmp(&buffer[fs], "srcidx", fl) == 0)
+        {
+            op.u.net_rule.src_vif |= anton(&buffer[ts], tl);
+        }
+        else if (strncmp(&buffer[fs], "dstdom", fl) == 0)
+        {
+            op.u.net_rule.dst_vif |= anton(&buffer[ts], tl)<<VIF_DOMAIN_SHIFT;
+        }
+        else if (strncmp(&buffer[fs], "dstidx", fl) == 0)
+        {
+            op.u.net_rule.dst_vif |= anton(&buffer[ts], tl);
+        }
+        else if ( (strncmp(&buffer[fs], "proto", fl) == 0))
+        {      
+            if (strncmp(&buffer[ts], "any", tl) == 0) 
+                op.u.net_rule.proto = NETWORK_PROTO_ANY; 
+            if (strncmp(&buffer[ts], "ip", tl) == 0)
+                op.u.net_rule.proto = NETWORK_PROTO_IP;
+            if (strncmp(&buffer[ts], "tcp", tl) == 0) 
+                op.u.net_rule.proto = NETWORK_PROTO_TCP;
+            if (strncmp(&buffer[ts], "udp", tl) == 0)
+                op.u.net_rule.proto = NETWORK_PROTO_UDP;
+            if (strncmp(&buffer[ts], "arp", tl) == 0)
+                op.u.net_rule.proto = NETWORK_PROTO_ARP;
+        }
     }
-  }
 
  doneparsing:  
-  ret = HYPERVISOR_network_op(&op);
-  return(len);
+    ret = HYPERVISOR_network_op(&op);
+    return(len);
 
  bad:
-  return(len);
+    return(len);
     
     
 }
@@ -256,51 +272,50 @@ int anton(const char *buff, int len)
     
 u16 antous(const char *buff, int len)
 {
-  u16 ret;
-  char c;
+    u16 ret;
+    char c;
 
-  ret = 0;
+    ret = 0;
 
-  while ( (len) && ((c = *buff) >= '0') && (c <= '9') )
-  {
-    ret *= 10;
-    ret += c - '0';
-    buff++; len--;
-  }
+    while ( (len) && ((c = *buff) >= '0') && (c <= '9') )
+    {
+        ret *= 10;
+        ret += c - '0';
+        buff++; len--;
+    }
 
-  return ret;
+    return ret;
 }
 
 u32 getipaddr(const char *buff, unsigned int len)
 {
-  int i; 
-  char c;
-  u32 ret, val;
+    char c;
+    u32 ret, val;
 
-  ret = 0; val = 0;
+    ret = 0; val = 0;
 
-  while ( len )
-  {
-    if (!((((c = *buff) >= '0') && ( c <= '9')) || ( c == '.' ) ) ) 
+    while ( len )
     {
-      return(0); // malformed.
+        if (!((((c = *buff) >= '0') && ( c <= '9')) || ( c == '.' ) ) ) 
+        {
+            return(0); // malformed.
+        }
+
+        if ( c == '.' ) {
+            if (val > 255) return (0); //malformed.
+            ret = ret << 8; 
+            ret += val;
+            val = 0;
+            len--; buff++;
+            continue;
+        }
+        val *= 10;
+        val += c - '0';
+        buff++; len--;
     }
+    ret = ret << 8;
+    ret += val;
 
-    if ( c == '.' ) {
-      if (val > 255) return (0); //malformed.
-      ret = ret << 8; 
-      ret += val;
-      val = 0;
-      len--; buff++;
-      continue;
-    }
-    val *= 10;
-    val += c - '0';
-    buff++; len--;
-  }
-  ret = ret << 8;
-  ret += val;
-
-  return (ret);
+    return (ret);
 }